package servlet.article;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.ArticleService;

/**
 * Servlet implementation class ArticleDeleteServlet
 */
@WebServlet("/ArticleDeleteServlet")
public class ArticleDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ArticleDeleteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1  获取id
		String id = request.getParameter("id");
		
		//2  articles集合中删除这个元素 
		ArticleService service = new ArticleService();
		
		service.delete(id);
		
		//3  重定向到ArticleListServlet
		response.sendRedirect("ArticleListServlet");
	}

	

}
